import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import Bus from './js/bus.js'
import {Loadmore, Toast } from 'mint-ui'
import '@/js/global';
import VueClipboards from 'vue-clipboards';

Vue.use(VueClipboards);
window._ = require('lodash');

Vue.component(Loadmore.name, Loadmore);
Vue.use(Bus)

Vue.config.productionTip = false
Vue.prototype.$toast = (args) => {
    if (typeof args === 'string') {
        return Toast({
            message: args
        });
    } else {
        return Toast({
            ...args,
        });
    }
}
// axios 拦截器
axios.interceptors.response.use(response => {
    return response
}, error => {
    if (error.response) {
        // Toast(error.response.status)
        if (error.response.status === 400) {
            if(error.response.data.error != "暂时没有匹配的任务" && error.response.data.error != "请选择默认任务号"){
                if(error.response.data.errorCode != 95515){
                    Toast(error.response.data.error);
                }
            }
            //这是一个注释
        } else if (error.response.status === 401) {
            router.push({
                path: '/task/Login'
            })
            Toast(error.response.data.error);
        } else {
            // Toast(error.response);
        }
    }
    return Promise.reject(error.response.data)
})

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    components: {App},
    template: '<App/>'
})
